﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WJP.Queue.Socketing.BufferManagement
{
    /// <summary>
    /// 缓存池基本接口
    /// </summary>
    public interface IPool
    {
        /// <summary>
        /// 获取总数
        /// </summary>
        int TotalCount { get; }

        /// <summary>
        /// 获取可用数量
        /// </summary>
        int AvailableCount { get; }

        /// <summary>
        /// 缩减这个池
        /// </summary>
        /// <returns></returns>
        bool Shrink();
    }

    /// <summary>
    /// T类型中对象的基本池接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IPool<T> : IPool
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        T Get();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        void Return(T item);
    }
}
